import java.net.InetAddress;
import java.net.UnknownHostException;

import ca.etsmtl.log730.lab3.controllers.BranchController;
import ca.etsmtl.log730.lab3.events.bank.HelloEvent;
import ca.etsmtl.log730.lab3.view.BranchSuccursale;


public class MainBranch {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		final BranchSuccursale bs = new BranchSuccursale();
		
		
		/*
		 * Assignation des params pour la succursale
		 */
		try {
			bs.getBranchController().
			getBranch().
			setName("LA SUCCURSALE: " + 
					(int)(Math.random()*100d));
			byte addr[] = InetAddress.getLocalHost().getAddress();
			bs.getBranchController().getBranch().setIpAddress(
					addr[0] + "." +
					addr[1] + "." +
					addr[2] + "." +
					addr[3]);
			bs.getBranchController().getBranch().setPort(bs.getBranchController().getBranchBankPort());
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
		bs.getBranchController().open();
		bs.setVisible(true);
		HelloEvent ee = new HelloEvent("CONNECTED", bs.getBranchController().getBranch());
		bs.getBranchController().getMainConnector().addEvent(ee);
		
	
	}

}
